package com.qfedu.knowledge.entity.dto;

import com.qfedu.knowledge.entity.bo.QuestionInfoBO;
import com.qfedu.knowledge.entity.enums.SubjectTypeEnum;
import lombok.Builder;
import lombok.Data;

/**
 * @ClassName AddQuestion4ESDTO
 * @Author ykx
 * @Date 2024/4/17 12:00
 * @Version 1.0
 */
@Data
@Builder
public class AddQuestion4ESDTO {

    /**
     * id
     */
    private Long id;

    /**
     * 编码
     */
    private String code;

    /**
     * 题目
     */
    private String question;

    /**
     * 选项A
     */
    private String optionA;

    /**
     * 选项B
     */
    private String optionB;

    /**
     * 选项C
     */
    private String optionC;

    /**
     * 选项D
     */
    private String optionD;

    /**
     * 答案选项
     */
    private String answerOption;

    /**
     * 答案
     */
    private String answer;

    /**
     * 类型
     */
    private String typeName;

    public static AddQuestion4ESDTO buildQuestion4ES(QuestionInfoBO questionInfoBO) {
        return AddQuestion4ESDTO.builder()
                .id(questionInfoBO.getId())
                .code(questionInfoBO.getCode())
                .question(questionInfoBO.getQuestion())
                .optionA(questionInfoBO.getOptionA())
                .optionB(questionInfoBO.getOptionB())
                .optionC(questionInfoBO.getOptionC())
                .optionD(questionInfoBO.getOptionD())
                .answerOption(questionInfoBO.getAnswerOption())
                .typeName(SubjectTypeEnum.getValueByCode(questionInfoBO.getType()))
                .build();
    }

}
